home *** CD-ROM | disk | FTP | other *** search
- /*
- dshell v3
-
- 背景にスケールを描く
- */
-
- #include "dsh.h"
-
-
- static void disp_mesh_item(const char **);
- static void mesh_exec(short , short , short );
-
-
- #define ITEMS 6
- #define WIN_SX 34
- #define WIN_SY 24
- #define MAX_MESLEN 6
-
-
- /*
- メッシュメニューの表示する
- */
- static void
- disp_mesh_item(const char **ptr)
- {
- int i;
-
- for (i = 0; i < ITEMS; i++) {
- B_LOCATE(WIN_SX, WIN_SY + i);
- B_PRINT(ptr[i]);
- }
- }
-
-
-
- void
- Menu_mesh()
- {
- int dmx, dmy, mbl, mbr, mx, my;
- int ty, oty;
- static short x_style = 0x0000, y_style = 0x0000; /* x,yのラインスタイル初期値 */
-
- static const char *menu[ITEMS] =
- {
- "横直線",
- "横破線",
- "縦直線",
- "縦破線",
- "線消去",
- " 終了 "
- };
-
- tbox_w2(WIN_SX, WIN_SY, WIN_SX + MAX_MESLEN, WIN_SY + ITEMS);
- msarea(WIN_SX * 8, WIN_SY * 16, (WIN_SX + MAX_MESLEN) * 8, (WIN_SY + ITEMS) * 16 - 4);
-
- /*
- ! メニュー表示
- */
- B_COLOR(3);
- disp_mesh_item(menu);
-
- /*
- ! マウスなど離されるの待ち
- */
- wait_mb_off();
-
- oty = -1; /* 古い座標なんてもってないから */
- while (1) {
-
- dmsstat(&dmx, &dmy, &mbl, &mbr);
- dmspos(&mx, &my);
- p_time(0);
-
- /*
- ! ライトダウンで終了
- */
- if (mbr == -1) {
- break;
- }
- /*
- ! レフトダウンで実行
- */
- if (oty != -1 && mbl == -1) {
- short lflag = 0;
-
- /*
- ! セレクトされているメニューの実行
- ! パラメータセットの場所
- */
- switch (oty) {
- case 0:
- y_style = 0xFFFF;
- lflag = 2;
- break;
- case 1:
- y_style = 0xCCCC;
- lflag = 2;
- break;
- case 2:
- x_style = 0xFFFF;
- lflag = 1;
- break;
- case 3:
- x_style = 0xCCCC;
- lflag = 1;
- break;
- case ITEMS - 2:
- case ITEMS - 1:
- default:
- break;
- };
-
- /*
- ! 実際に処理を振り分けるとこ
- */
- if (oty == ITEMS - 1) { // 終了
- break;
- } if (oty == ITEMS - 2) { // 消去
- fill(0, 16, 767, 495, 0);
- } else {/* メッシュ実行を選んだか? */
- mesh_exec(x_style, y_style, lflag);
- }
-
- }
- /*
- ! ヌルイベント
- */
- {
- ty = (my - WIN_SY * 16) / 16;
- if (ty != oty && ty >= 0 && ty < ITEMS) { /* Y座標が更新されたか? */
- disp_mesh_item(menu);
- B_LOCATE(WIN_SX, WIN_SY + ty);
- B_COLOR(13);
- B_PRINT(menu[ty]);
- B_COLOR(3);
- }
- oty = ty;
- }
- }
-
-
- /*
- ! ウィンドウを元に戻す
- */
- msarea(0, 0, GWIDTH - 1, 511);
- {
- int i;
-
- for (i = WIN_SY - 2; i <= 29; i++) {
- p_lin(lp + i, i);
- }
- }
-
- /*
- ! マウスなど離されるの待ち
- */
- wait_mb_off();
-
- }
-
- /*
- メッシュ処理をするですのところ
- ようするに描く場所なわけだ
-
- flagのビット0がオンなら縦線、
- ビット1がオンなら横線を引く。(両方オンなら両方引く)
- */
- static void
- mesh_exec(short x_style, short y_style, short flag)
- {
- #define SX 0 /* Start */
- #define SY 16
- #define EX (GWIDTH-1) /* End */
- #define EY 495
- #define OX 8 /* Offset */
- #define OY 16
-
-
- #define FRONT_COLOR 0 /* バックのパレット番号 */
- #define BACK_COLOR 2 /* 線のパレット番号 */
-
-
- int x, y;
-
- if (flag & 0x1) { /* 縦線 */
- for (x = SX; x < EX; x += OX) {
- line(x, SY, x, EY, FRONT_COLOR, 0xffff); /* まず消す */
- if (x_style) {
- line(x, SY, x, EY, BACK_COLOR, x_style);
- }
- }
- }
- if (flag & 0x2) { /* 横線 */
- for (y = SY + 15; y < EY + 15; y += OY) {
- line(SX, y, EX, y, FRONT_COLOR, 0xffff); /* まず消す */
- if (y_style) {
- line(SX, y, EX, y, BACK_COLOR, y_style);
- }
- }
- }
- }
-
- /* [ EOF ] */
-